package com.alibaba.cloud.client9093.config;

import com.alibaba.csp.sentinel.adapter.spring.webmvc.callback.UrlCleaner;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.math.NumberUtils;
import org.springframework.stereotype.Component;

import java.util.LinkedList;

/**
 * created by wuquan at 05/09/2021
 * ^_^ ^_^
 * 当多次请求 /getUserById/{id} -->   /getUserById/1,/getUserById/2.....
 * 会产生很多不同的资源名，无法统一管理，因此实现资源名统一定义为 /getUserById/{id}
 * 注意：2.2.0以上版本，不许配置
 */
@Slf4j
//@Component
public class MyCustomUrlClean implements UrlCleaner {

    @Override
    public String clean(String originUrl) {

        if (StringUtils.isEmpty(originUrl)) {
            return originUrl;
        }
        log.info(originUrl);

        if (originUrl.startsWith("/getUserById")) {
            return "/getUserById/{id}";
        }
        return originUrl;
    }


    public static void main(String[] args) {
        LinkedList<String> list = new LinkedList<>();
        //Math.max()
    }

}
